home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 March / Macworld CD-ROM (March 1995).cdr / Updaters / AppMaker 1.5.2->1.5.4 / Libraries / THINK / AMClassLibC / CAMPopupPane.cp < prev    next >
Encoding:
Text File  |  1991-11-24  |  3.4 KB  |  116 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CAMPopupPane.c
  3.         
  4.     
  5.     Like the StdPopupPane class that it overrides, except that font, size and
  6.     style can be set from an 'APop' resource.
  7.  
  8.     SUPERCLASS = CStdPopupPane
  9.     
  10.     Copyright © 1991 Bowers Development Corporation. All rights reserved.
  11.  
  12.  ******************************************************************************/
  13.  
  14. #include <Sound.h>
  15. #include "CAMPopupMenu.h"
  16. #include "CAMPopupPane.h"
  17.  
  18. /******************************************************************************
  19.  IViewTemp
  20.  
  21.      Initialize a PopupPane using a template
  22.  
  23. ******************************************************************************/
  24. void    CAMPopupPane::IViewTemp        (CView            *anEnclosure,
  25.                                       CBureaucrat    *aSupervisor,
  26.                                      Ptr            viewData)
  27. {
  28.     register AMPopupTempP        p;
  29.  
  30.     p = (AMPopupTempP) viewData;
  31.     saveTypeStyleP = &p->typeStyle;
  32.     inherited::IViewTemp (anEnclosure, aSupervisor, (Ptr)&p->sStdPopupTemp);
  33.  
  34. } /* IViewTemp */
  35.  
  36. /******************************************************************************
  37.  MakePopupMenu {OVERRIDE}
  38.  
  39.      Creates the PopupMenu owned by the PopupPane. Override to create
  40.      a subclass of CPopupMenu.
  41. ******************************************************************************/
  42.  
  43. void    CAMPopupPane::MakePopupMenu    (short            menuID, 
  44.                                      Boolean        fAutoSelect,
  45.                                      Boolean        fMultiSelect)
  46. {
  47.     CAMPopupMenu        *aMenu;
  48.     short                fontNum;
  49.     
  50.     fontNum = AMGetFontNum (saveTypeStyleP->fontName);
  51.  
  52.     aMenu = new CAMPopupMenu;
  53.     aMenu->IAMPopupMenu (menuID, this, fAutoSelect, fMultiSelect,
  54.                             fontNum, 
  55.                             saveTypeStyleP->textSize);
  56.     itsMenu = aMenu;
  57.  
  58. } /* MakePopupMenu */
  59.  
  60. /******************************************************************************
  61.  CalcDimensions    {OVERRIDE}
  62.  
  63.      If this is the first time through (the "saveViewData" pointer isn't NIL)
  64.      then set the font, size and style instance variables.  Otherwise, just
  65.      call the inherited method.
  66.      This is being done to make sure that font, size and style are correct
  67.      before CalcDimensions is called the first time.
  68.  
  69. ******************************************************************************/
  70. void    CAMPopupPane::CalcDimensions        (void)
  71. {
  72.     if (saveTypeStyleP != nil) {        /* first time through */
  73.         textFont = AMGetFontNum (saveTypeStyleP->fontName);
  74.         textSize = saveTypeStyleP->textSize;
  75.         saveTypeStyleP = nil;
  76.     }
  77.     inherited::CalcDimensions ();
  78.  
  79. } /* CalcDimensions */
  80.  
  81. /******************************************************************************
  82.  NewMenuSelection {OVERRIDE}
  83.  
  84.      Receive notification of a new menu selection. Broadcast the change
  85.      to our supervisor.
  86. ******************************************************************************/
  87.  
  88. void    CAMPopupPane::NewMenuSelection        (short        itemSelected)
  89. {
  90.     BroadcastChange (popupMenuNewSelection, &itemSelected);
  91.  
  92.     inherited::NewMenuSelection (itemSelected);
  93.  
  94. } /* NewMenuSelection */
  95.  
  96. /******************************************************************************
  97.  PlaySound
  98.  
  99.      For a "Sounds" menu: play the sound named by the itemNr.
  100. ******************************************************************************/
  101.  
  102. void    CAMPopupPane::PlaySound        (short            itemNr)
  103. {
  104.     Str255            soundName;
  105.     Handle            sound;
  106.     OSErr            errCode;
  107.  
  108.     GetItem (itsMenu->GetMacMenu (), itemNr, soundName);
  109.     sound = GetNamedResource ('snd ', soundName);
  110.     if (sound != NULL) {
  111.         errCode = SndPlay (NULL, sound, false);
  112.     }
  113. } /* PlaySound */
  114.  
  115. /* CAMPopupPane */
  116.